package com.huli.util;

import cn.hutool.json.JSONUtil;
import com.baidu.aip.ocr.AipOcr;
import com.huli.vo.IdCardVO;
import org.json.JSONObject;

import java.util.HashMap;

public class IdCardCheck {

    public static IdCardVO idCardCheck(String url, Integer side, AipOcr client){
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<>();
        options.put("detect_direction", "true");
        options.put("detect_risk", "false");

        String idCardSide = side == 1 ? "front" : "back";

        // 参数为本地图片路径
        JSONObject res = client.idcard(url, idCardSide, options);

        return JSONUtil.toBean(res.toString(), IdCardVO.class);
    }

}
